import java.util.Scanner;

/*
 * @author zzr
 * @date: 2025/10/17  19:49
 * @description:
 * 编写一个程序，读入用户输入的先序遍历的字符串，根据此字符串建立一个二叉树
 * 并对建立的二叉树进行中序遍历
 */
public class Demo25 {

    class TreeNode {
        char val;
        TreeNode left;
        TreeNode right;
        TreeNode() {}
        TreeNode(char val) {
            this.val = val;
        }
    }
    public void inOrder(TreeNode root) {

        if (root == null) return;
        inOrder(root.left);
        System.out.println(root.val + " ");
        inOrder(root.right);
    }

    private int i = 0;
    public TreeNode createTree(String str) {
        TreeNode root = null;
        if (str.charAt(i) != '#') {
            root = new TreeNode(str.charAt(i));
            i++;
            root.left = createTree(str);
            root.right = createTree(str);
        } else {
            i++;
        }
        return root;
    }
}
